package com.eye.catcher.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eye.catcher.entity.TYwDaBaseInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 基地表 Mapper 接口
 * </p>
 *
 * @author huzhiwei
 * @since 2022-05-12
 */
@Mapper
public interface TYwDaBaseInfoMapper extends BaseMapper<TYwDaBaseInfo> {
    String querySql = " select b.*," +
            " ( SELECT count( 1 ) FROM t_yw_da_field_info WHERE BASE_ID = b.id ) fileCount " +
            " from t_yw_da_base_info b ";

    String wrapperSql = " select * from (" + querySql + ") as q ${ew.customSqlSegment}";
    @Select(wrapperSql)
    List<TYwDaBaseInfo> list(@Param("ew") QueryWrapper<TYwDaBaseInfo> wrapper);
    @Select(wrapperSql)
    IPage<TYwDaBaseInfo> page(Page<TYwDaBaseInfo> page,@Param("ew") QueryWrapper<TYwDaBaseInfo> wrapper);
}
